﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;

namespace GIAODIEN
{
    public partial class frmdangnhap : Form
    {
        public frmdangnhap()
        {
            InitializeComponent();
        }
        public void kiemtradangnhap(string tendn, string matkhau)
        {
            DataTable dt = new DataTable();
            dt = BUS_nhanvien.dangnhap(tendn, matkhau);
            bientoancuc.loaidn= BUS_nhanvien.kiemtraloai(tendn);
            if (dt.Rows.Count == 1)
            {
              
                this.Hide();
                frmquanly frm = new frmquanly();
                frm.Show();
                bientoancuc.ttnhanvien.TenNhanVien = dt.Rows[0][1].ToString();
                bientoancuc.ttnhanvien.MaNhanVien =dt.Rows[0][0].ToString();
 
            }
            else
            {
                lblthongbao.Text = "Tên đăng nhập hoặc mật khẩu không chính xác";
            }

        }
        private void btndangnhap_Click(object sender, EventArgs e)
        {
            kiemtradangnhap(txttendangnhap.Text, txtmatkhau.Text);
        }

        private void frmdangnhap_Load(object sender, EventArgs e)
        {

        }

        private void btnthoat_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
